package insight.Builder;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

/**
 * @author huu
 * @create 2025-08-26-14:44
 */
public class Main {
    public static void main(String[] args) {
        //像不像builder构造器
        User1 builder = new User1
                .Builder("huu", 18)
                .build();
        //完整的,httpClient里面还有那啥接口在实现
        User user = User.builder()
                .name("huu")
                .age(18)
                .build();

        List<String> collect = List.of(1, -1, 2).stream().map(String::valueOf).filter(s -> s.length() > 1).collect(Collectors.toList());
        System.out.println( collect);
        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> "huu");
        //CompletableFuture ----更高级的建造者模式---DSL
        //CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> "huu")

        String sql = SQL.builder(SQL.SqlType.SELECT).columns("name", "age").table("user").where("id = 1").build();
        System.out.println( sql);
        System.out.println(SQL.builder(SQL.SqlType.UPDATE).set("name", "TTDB").table("user").build());
        //System.out.println(SQL.select("name", "age").from("user").where("age =100").build());
        System.out.println(SQL.update("user").set("name", "TTDB").where("id = 1").where("age =100").build());
        //这里将引入一个接口的做法来保证在构造时每一个只会被允许调用一次，你可以在CompletableFutrue中看见这个
        //这里你在.table后再.table就是做不到了
        System.out.println(SQL.select("name", "age").table("user").where("age =100").build());

        //插入
        System.out.println(SQL.insert().insert("name", "TTDB").table("user").build());
        //删除
        System.out.println(SQL.delete().table("user").where("id = 1").build());

    }
}
